home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / pcr / pcr4_4.lha / DIST / loading / testjmp.c < prev    next >
C/C++ Source or Header  |  1989-04-03  |  3KB  |  128 lines

  1. /* begincopyright
  2.   Copyright (c) 1988 Xerox Corporation. All rights reserved.
  3.   Use and copying of this software and preparation of derivative works based
  4.   upon this software are permitted. Any distribution of this software or
  5.   derivative works must comply with all applicable United States export
  6.   control laws. This software is made available AS IS, and Xerox Corporation
  7.   makes no warranty about the software, its performance or its conformity to
  8.   any specification. Any person obtaining a copy of this software is requested
  9.   to send their name and post office or electronic mail address to:
  10.     PCR Coordinator
  11.     Xerox PARC
  12.     3333 Coyote Hill Rd.
  13.     Palo Alto, CA
  14.   endcopyright */
  15. /* Copyright 1987, Xerox, Inc., 
  16.  *    written by Mark Weiser
  17.  *
  18.  * $Log:    testjmp.c,v $
  19.  * Revision 1.4  88/09/10  21:56:19  xr
  20.  * *** empty log message ***
  21.  * 
  22.  * Revision 1.3  88/09/10  21:41:46  xr
  23.  * *** empty log message ***
  24.  * 
  25.  * Revision 1.2  88/09/10  21:37:23  xr
  26.  * *** empty log message ***
  27.  * 
  28.  * Revision 1.1  88/09/10  21:22:00  xr
  29.  * Initial revision
  30.  * 
  31.  */
  32. #ifndef lint
  33. static char rcsid[] = "$Header: testjmp.c,v 1.4 88/09/10 21:56:19 xr Exp $";
  34. #endif
  35.  
  36. #include <stdio.h>
  37. #include <sys/types.h>
  38. #include <setjmp.h>
  39. #include <xr/unwind.h>
  40.  
  41. struct LDGLOBAL ldglobal_real, *ldglobal = &ldglobal_real;
  42.  
  43. jmp_buf jb;
  44.  
  45.  
  46. xr_jmp_buf cjb;
  47.  
  48. #if 1
  49. #define CEDAR
  50. #endif
  51. #ifdef CEDAR
  52. #define LONGJMP    xr_longjmp
  53. #else
  54. #define LONGJMP    _longjmp
  55. #endif
  56.  
  57. typedef int RegType;
  58.  
  59. XR_StartMainXR()
  60. {
  61.   extern int XR_argc;
  62.   extern char **XR_argv;
  63.   int argc = XR_argc;
  64.   char **argv = XR_argv;
  65.     register RegType a, b, c, d, e, f, g, h, i, j, k, l, m, n;
  66.     a = (RegType)1; b = (RegType)2; c = (RegType)3; d = (RegType)4; e = (RegType)5; f = (RegType)6; g = (RegType)7; h = (RegType)8; i = (RegType)9;
  67.     j = (RegType)10; k = (RegType)11; l = (RegType)12; m = (RegType)13; n = (RegType)14;
  68.     if (! init_dyload(argv[0])) {
  69.         printf("Something wrong in init_dyload.\n");
  70.         abort();
  71.     }
  72. #ifdef CEDAR
  73.     if (xr_setjmp (&cjb, 0)) {
  74. #else
  75.     if (_setjmp(&cjb)) {
  76. #endif
  77.         printf("Got a non-zero return from xr set_jmp, vals: ");
  78.         dump_vars(a, b, c, d, e, f, g, h, i, j, k, l, m, n);
  79.         printf("Above should be all 43's\n");
  80.         exit(0);
  81.     } else {
  82.         printf("Got a zero return from xr set_jmp, vals: ");
  83.         dump_vars(a, b, c, d, e, f, g, h, i, j, k, l, m, n);
  84.         printf("Above should be all 1 through 14.\n");
  85.     }
  86.      a = (RegType)43; b = (RegType)43; c = (RegType)43; d = (RegType)43; e = (RegType)43; f = (RegType)43; g = (RegType)43; h = (RegType)43; i = (RegType)43;
  87.     j = (RegType)43; k = (RegType)43; l = (RegType)43; m = (RegType)43; n = (RegType)43;
  88.     /* use_vars(a, b, c, d, e, f, g, h, i, j, k, l, m, n); */
  89.     godeep();
  90.     exit();
  91. }
  92.  
  93. godeep()
  94. {
  95. register RegType x,y;
  96. x = (RegType)19;
  97. y = (RegType)33;
  98. godeeper(x,y);
  99. }
  100.  
  101. godeeper(a,b)
  102. {
  103. register RegType y;
  104. y = (RegType)30;
  105. /* use_vars(y,z);*/
  106. smash_regs();
  107. }
  108.  
  109. smash_regs()
  110. {
  111.     register RegType a, b, c, d, e, f, g, h, i, j, k, l, m, n;
  112.     a = 0; b = 0; c = 0; d = 0; e = 0; f = 0; g = 0; h = 0; i = 0;
  113.     j = 0; k = 0; l = 0; m = 0; n = 0;
  114. /*    printf("Inside smash_regs: ");
  115.     printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",a, b, c, d, e, f, g, h, i, j, k, l, m, n);
  116. */    LONGJMP(&cjb,1);
  117. }
  118.  
  119. dump_vars(a, b, c, d, e, f, g, h, i, j, k, l, m, n)
  120. {
  121.     printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",a, b, c, d, e, f, g, h, i, j, k, l, m, n);
  122. }
  123.  
  124. use_vars(a, b, c, d, e, f, g, h, i, j, k, l, m, n)
  125. {
  126. }
  127.  
  128.